//
//  AppDelegate.swift
//  YMSWeibo
//
//  Created by 杨茂盛 on 2016/11/12.
//  Copyright © 2016年 杨茂盛. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    
    var window: UIWindow?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        //注册通知
        regisNotification()
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        //        let TabVc = YMSMainTabBarController()
    
        window?.rootViewController =  YMSMainTabBarController()

        window?.makeKeyAndVisible()
        
        //可视化的时候设置检测帧率的框架
        JPFPSStatus.sharedInstance().open()
        return true
    }
    //MARK: 注册通知
    private func regisNotification(){
        NotificationCenter.default.addObserver(self, selector: #selector(switchRootViewController(n:)), name: NSNotification.Name(rawValue: choseRootViewController), object: nil)
    }
   @objc private func switchRootViewController(n:Notification){
    //登录界面如果为空,说明已经登陆过了,那么就显示tabbar控制器,否则显示登录界面
    let Vc = n.object == nil ?YMSMainTabBarController():YMSOAuthWellcomeController()
    window?.rootViewController = Vc
    }
    //移除通知
    deinit {
        NotificationCenter.default.removeObserver(self)
    }
    
    
    func applicationDidEnterBackground(_ application: UIApplication) {
        //添加cover 高斯模糊
        //清除缓存数据
        YMSStatusDal.clearCacheStatus()
    }

}

